Skip to content

[NFCI] Remove getLifetimeStartIntrinsic function from SPIRVReader#3373

Merged
MrSidims merged 2 commits intoKhronosGroup:mainfrom
MrSidims:remove-not-needed-user-check
Oct 2, 2025
Merged

[NFCI] Remove getLifetimeStartIntrinsic function from SPIRVReader#3373
MrSidims merged 2 commits intoKhronosGroup:mainfrom
MrSidims:remove-not-needed-user-check

Conversation

@MrSidims
Copy link
Contributor

@MrSidims MrSidims commented Oct 1, 2025

With new lifetime.start/end rules, which are:
"The argument is either a pointer to an alloca instruction or a poison
value."
it became obsolete on main branch. Note, no test is possible to add
on the main branch.

Moreover, it seem to be redundant overall, as IR like this was legal:
%0 = alloca ...
%1 = bitcast %0
call void @llvm.lifetime.start(..., %1)
%2 = bitcast %0
call void @llvm.lifetime.end(..., %2)

Further implecations, and why this patch will be backported on older
branches. Right now there is a possibility to have a round-trip
translation failed, when it goes from main to pre-opaque pointers
branches as a bitcast from alloca to i8* will be inserted before
lifetime.start call. Later, due to the current logic, this bitcast will
be reused for lifetime.end call. But, lifetime.end won't always post-dominate
lifetime.start (in this case the object will be considered dead at
function return block), hence the bitcast won't dominate the
lifetime.stop call, invalidating the generated module.

Signed-off-by: Sidorov, Dmitry dmitry.sidorov@intel.com

Sidorov, Dmitry added 2 commits October 1, 2025 06:51
wip
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
With new lifetime.start/end rules, which are:
"The argument is either a pointer to an alloca instruction or a poison
value."
it became obsolete on main branch.

Moreover, it seem to be redundant overall, as IR like this was legal:
  %0 = alloca ...
  %1 = bitcast %0
  call void @llvm.lifetime.start(..., %1)
  %2 = bitcast %0
  call void @llvm.lifetime.end(..., %2)

Further implecations, and why this patch will be backported on older
branches. Right now there is a possibility to have a round-trip
translation failed, when it goes from main to pre-opaque pointers
branches as a bitcast from alloca to i8* will be inserted before
lifetime.start call. Later, due to the current logic, this bitcast will
be reused for lifetime.end call. But, lifetime.end won't always post-dominate
lifetime.start (in this case the object will be considered dead at
function return block), hence the bitcast won't dominate the
lifetime.stop call, invalidating the generated module.

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
@MrSidims MrSidims requested review from svenvh and vmaksimo October 1, 2025 14:00
@MrSidims
Copy link
Contributor Author

MrSidims commented Oct 1, 2025

@maarquitos14 @YuriPlyakhin @YixingZhang007 please help with the review.

Copy link
Contributor

@YuriPlyakhin YuriPlyakhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me and also backporting it as well

Copy link
Contributor

@YixingZhang007 YixingZhang007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Thanks

@MrSidims MrSidims merged commit 8ff5355 into KhronosGroup:main Oct 2, 2025
9 checks passed
dm-vodopyanov pushed a commit to intel/llvm that referenced this pull request Oct 9, 2025
#20287)

SPIRVReader has contained a bug for a long time, fixed in
KhronosGroup/SPIRV-LLVM-Translator#3373

While the proper fix will be backported to earlier branches - it still
will take a lot of time for adoption by LTS driver. Hence we have to add
a W/A restoring old behaviour of lifetime intrinsics translation,
inserting artificial bitcast to i8*.

PR also includes update of a test from
KhronosGroup/SPIRV-LLVM-Translator#3376

---------

Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
@MrSidims
Copy link
Contributor Author

/backport to llvm_release_210

@github-actions
Copy link

Invalid backport command. Expected /backport llvm_release_<digits>

@MrSidims
Copy link
Contributor Author

/backport llvm_release_210

@github-actions
Copy link

Attempting to create backport to llvm_release_210...

@github-actions
Copy link

Backport to llvm_release_210 failed due to conflicts on commit 8ff535506896489be777e4fa6adeedaadcae981b. Please backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants